define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.user/index',
        add_url: 'mall.user/add',
        edit_url: 'mall.user/edit',
        delete_url: 'mall.user/delete',
        export_url: 'mall.user/export',
        modify_url: 'mall.user/modify',
    };

    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                height:'full-50',
                toolbar: ['refresh',
                    [],
                    'export'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id'},
                    {field: 'openid', title: '用户识别号'},
                    {field: 'nickName', title: '用户昵称'},
                    {field: 'avatarUrl', title: '用户头像', templet: ea.table.image},
                    {field: 'mobile', title: '手机号'},
                    {field: 'levelname', title: '分销商等级',search: false},
                    {field: 'type', search: 'select', selectList: ["小程序","微信公众号"], title: '用户类型'},
                    {field: 'balance', search: false,  title: '直推余额'},
                    {field: 'againbalance', search: false,  title: '业绩余额'},
                    {field: 'teambalance', search: false,  title: '团队余额'},
                    {field: 'parent_name', title: '推荐人',search: false},
                    {field: 'create_time', title: '创建时间'},
                    // {field: 'status', search: 'select', selectList: ["禁用","启用"], title: '状态', templet: ea.table.switch},
                    {
                        width: 200,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                            }],
                        ]
                    }
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});